Converting a table to a matrix